package com.fypg.module.medical.service.organizationmap;

import com.fypg.framework.common.util.object.BeanUtils;
import com.fypg.module.medical.controller.app.map.vo.AppMapRespVO;
import com.fypg.module.medical.controller.app.map.vo.AppOrganizationMapReqVO;
import com.fypg.module.medical.controller.app.map.vo.AppOrganizationMapRespVO;
import com.fypg.module.medical.dal.dataobject.organizationmap.OrganizationMapDO;
import com.fypg.module.medical.dal.mysql.organizationmap.OrganizationMapMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 医疗机构地图 Service 实现类
 *
 * @author PJY
 */
@Service
@Validated
public class OrganizationMapServiceImpl implements OrganizationMapService {

    @Resource
    private OrganizationMapMapper organizationMapMapper;

    @Override
    public AppMapRespVO<AppOrganizationMapRespVO> getOrganizationMapList(AppOrganizationMapReqVO reqVO) {
        List<OrganizationMapDO> organizationMapDOList = organizationMapMapper.selectList(reqVO);
        List<AppOrganizationMapRespVO> organizationMapRespVOList = BeanUtils.toBean(organizationMapDOList, AppOrganizationMapRespVO.class);
        return AppMapRespVO.<AppOrganizationMapRespVO>builder()
            .list(organizationMapRespVOList)
            .total(organizationMapRespVOList.size())
            .build();
    }

}
